package jdbc;

import jdk.nashorn.internal.ir.WhileNode;

import javax.xml.stream.events.StartElement;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

public class Demo5 {
    public static void main(String[] args) {
        try (Connection con=DBUtil.getConnection()) {
            Statement statement=con.createStatement();
            String sql="SELECT id,name,salary,title"+
                       " FROM teacher"+
                       " WHERE salary>6000";
            ResultSet res=statement.executeQuery(sql);
            while(res.next()){
                int id=res.getInt("id");
                String name=res.getString("name");
                int salary=res.getInt("salary");
                String title=res.getString("title");
                System.out.println(id+" "+name+" "+salary+" "+title+" ");
            }
        } catch (SQLException e) {
         e.printStackTrace();
        }
    }
}
